package com.itzxx.huazhun.data.model

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

/**
 * 探头基础信息
 */
@Parcelize
data class ProbeInfo(
    val battery: Int,
    val currentSamplingTimes: String,
    val feature: Int,
    val hw: Int,
    val mac: String,
    val model: String,
    val samplingTimesCapacity: String,
    val sw: Int,
    val wayIndex: String,
    val wayNum: Int
) : Parcelable {

    private lateinit var listSamplingData: MutableList<ProbeTestingInfo>


    fun plusReadAllTestIndex(): Int {
        return 1.plus(getList().size)
    }

    fun isAllReaded(): Boolean {
        return getList().size >=currentSamplingTimes.toInt()
    }

    fun getProbeType(): String {
        return if (wayIndex.contains("0") && wayIndex.contains("0")) {
            "气压、温度探头"
        } else if (wayIndex.contains("1")) {
            "单压探头"
        } else {
            "单温探头"
        }
    }

    fun addListSamplingData(list: List<ProbeTestingInfo>) {
        getList().addAll(list)
    }

    fun getList():MutableList<ProbeTestingInfo>{
        if (!::listSamplingData.isInitialized){
            listSamplingData = mutableListOf()
        }
        return listSamplingData
    }

    fun getSerialNumber(): String {
        val modelSplit = model.split("-")
        return try {
            modelSplit[modelSplit.size - 1]
        } catch (e: Exception) {
            model
        }
    }
}